#include <stdio.h>
#include <stdint.h>
#include <fcntl.h>

int main(int argc, char *argv[]){
    if(argc != 2){
        printf("[%s]:Usage:%s <file>\n", __func__, argv[1]);
        return -1;
    }

    int fd = open(argv[1], O_RDWR);
    if(fd < 0){
        perror("open");
        return -1;
    }
    
    int event;
    uint8_t button, value;
    while(1){
        read(fd, &event, sizeof(event));
        button = (event >> 8) & 0xff; 
        value = (event) & 0xff;
        printf("[%s]:button event : butto %u value %u\n",
                 __func__, (unsigned int)button, (unsigned int)(value));
    }

    close(fd);
    return 0;
}